package org.ziky.common.framework.wicket.markup.html.form;

import org.apache.wicket.markup.html.form.HiddenField;
import org.apache.wicket.model.IModel;
import org.ziky.common.framework.wicket.markup.model.FwModel;
import org.ziky.common.framework.wicket.util.AttributeUtil;

public class FwHiddenField<T> extends HiddenField<T> {
    private static final long serialVersionUID = 1L;

    public FwHiddenField(String id, Class<T> type) {
        super(id, type);
    }

    public FwHiddenField(String id, IModel<T> model, Class<T> type) {
        super(id, model, type);
    }

    public FwHiddenField(String id, IModel<T> model) {
        super(id, model);
    }

    public FwHiddenField(String id) {
        super(id);
    }

    public void setValue(String val) {
        setDefaultModel(new FwModel<String>(val));
    }

    public void setAttribute(String attribute, String value) {
        AttributeUtil.setAttribute(this, attribute, value);
    }

    public String getAttribute(String attribute) {
        return AttributeUtil.getAttribute(this, attribute);
    }

    public void appendAttribute(String attribute, String value) {
        AttributeUtil.appendAttribute(this, attribute, value);
    }

    public void prependAttribute(String attribute, String value) {
        AttributeUtil.prependAttribute(this, attribute, value);
    }

    public void replaceAttribute(String attribute, String value) {
        AttributeUtil.replaceAttribute(this, attribute, value);
    }

    public void setStyle(String value) {
        setAttribute("style", value);
    }

    public void clearStyle() {
        setAttribute("style", "");
    }
}
